// Copyright (C) 2007 XtractPro (Data Extraction Magazine)
// http://www.xtractpro.com, support@xtractpro.com
//
// This code is provided AS IS, with NO WARRANTY expressed or implied.
// Any use of this free open source code is at your own risk.
//
// You are hereby granted the right to use it and change it,
// provided that you acknowledge XtractPro somewhere in your
// source files, documentation, web site and application.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace XtractPro.Multimedia
{
    /// <summary>
    /// Very simple implementation of the CAPTCHA Image Generator,
    /// which allows customization of properties of a CaptchaImage
    /// _image instance through a propGrid PropertyGrid control.
    /// The image will be passed from _image's Image property
    /// in a pctImage PictureBox control, each time the user clicks
    /// on it. On double-click, setting the Text property of the _image
    /// instance to an empty string will actually generate a new random text.
    /// </summary>
    public partial class MainForm : Form
    {
        private CaptchaImage _image;

        public MainForm()
        {
            InitializeComponent();
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            propGrid.SelectedObject = _image = new CaptchaImage();
            pctImage.Image = _image.Image;
        }

        private void pctImage_Click(object sender, EventArgs e)
        {
            pctImage.Image = _image.Image;
        }

        private void pctImage_DoubleClick(object sender, EventArgs e)
        {
            _image.Text = "";
            pctImage.Image = _image.Image;
        }
    }
}